package com.hj.dapp.business.brand.controller;

import com.baomidou.mybatisplus.core.metadata.IPage;
import com.hj.dapp.business.brand.model.Brand;
import com.hj.dapp.business.brand.service.BrandService;
import com.hj.dapp.common.request.PageRequest;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.security.Principal;
import java.util.List;

/**
 * @author 胡奥程
 * @version 1.0
 * @date 2024/1/22
 */
@RestController
@RequestMapping("/brand")
public class BrandController {
    @Autowired
    private BrandService brandService;

    @GetMapping("/get/{id}")
    public Brand get(@PathVariable("id") Long id) {
        return brandService.get(id);
    }
    @GetMapping("/list")
    public List<Brand> list() {
        return brandService.list();
    }

    @DeleteMapping("/delete/{id}")
    public void delete(@PathVariable("id") Long id) {
        brandService.delete(id);
    }
    @PostMapping("/page")
    public IPage<Brand> page(@RequestBody PageRequest<Brand> page) {
        return brandService.page(page);
    }

    @PutMapping("/save")
    public void save(@RequestBody Brand brand, Principal principal) {
        brandService.save(brand, principal);
    }
    @PostMapping("/edit")
    public void edit(@RequestBody Brand brand,Principal principal) {
        brandService.edit(brand, principal);
    }
}
